// components/menuItem/menuItem.ts
var app=getApp();
Component({

  /**
   * 组件的属性列表
   */
  properties: {
    id:{
      "type":String
    },
    item:{
      "type":Object,
      "value":{
      imageUrl:"https://tse4-mm.cn.bing.net/th/id/OIP-C.TlcARrTXvRPArrYZlYSc3gHaE8?w=195&h=195&c=7&r=0&o=5&dpr=2&pid=1.7",
      title:"示例菜品",
      comment:3,
      site:"一饭三楼",
      price:12.00,
      canteenId:0
      }
    }
},

  /**
   * 组件的初始数据
   */
  data: {
  },

  /**
   * 组件的方法列表
   */
  methods: {
    goManageDetail(e){
      wx.navigateTo({
        url: '/pages/manage/manageFoodDetail?id='+this.id,
      })
    },
    goDelFood(e){
      wx.showModal({
        title: '再次确认',
        content: '是否删除该菜品',
        complete: (res) => {
          if (res.cancel) {
            
          }
      
          if (res.confirm) {
            wx.request({
              url: app.globalData.apiUrl+'/food/deleteFoodByIds',
              method:"POST",
              data:{
                "token":wx.getStorageSync('token'),
                "canteen_id":this.data.item.canteenId,
                "data":this.id
              },
              success:(res)=>{
                console.log(res);
                wx.showToast({
                  title: '删除成功',
                })
                this.triggerEvent('reload')
              }
            })
          }
        }
      })


    }
  }
})